import request from "@/utils/request";

// 用户登录
const UserLogin = (username, password) => {
    return request({
        url: "/users/login",
        method: "post",
        data: {
            username,
            password
        }
    });
};

// 管理员信息
const UserInfo = () => {
    return request({
        url: "/users/info"
    });
};

// 用户退出
const UserLogout = () => {
    return request({
        url: "/users/logout"
    });
};

// 用户列表
const UserList = (params) => {
    return request({
        url: "/users",
        params: {
            ...params
        }
    });
};
// 删除用户
const UserDelete = (id) => {
    return request({
        url: `/users/${id}`,
        method: "delete"
    });
};

// 添加用户
const UserAdd = (data) => {
    return request({
        url: "/users",
        method: "post",
        data
    });
};

// 修改用户
const UserUpdate = (id, data) => {
    return request({
        url: `/users/${id}`,
        method: "patch",
        data
    });
};

export {
    UserLogin,
    UserInfo,
    UserLogout,
    UserList,
    UserDelete,
    UserAdd,
    UserUpdate
};
